package com.hx.er.action.admin.settings;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.hx.er.action.base.ErAdminPageAction;
import com.hx.er.bean.detail.CityDetailBean;
import com.hx.er.common.system.Constants;
import com.hx.er.common.system.ErProperties;
import com.hx.er.common.util.StringUtil;
import com.hx.er.service.admin.IAdminSettingsService;

public class AdminCityListAction extends ErAdminPageAction {
	// 序列化ID
	private static final long serialVersionUID = 2487585146579189747L;

	private List<CityDetailBean> cityDetailList;
	private String localCityName;

	@Autowired
	private IAdminSettingsService adminSettingsService;

	public String init() {
		// 国家编号从系统配置中获取
		long countryId = Long.parseLong(ErProperties.getProperty(Constants.PROPERTY_DEFAULT_COUNTRY));
		Map<String, Object> conditions = super.getConditionMap();

		// 检索条件
		conditions.put("countryId", countryId);
		conditions.put("localCityName", StringUtil.EmptyToNull(StringUtil.trim(this.localCityName)));

		// 查询列表
		this.cityDetailList = this.adminSettingsService.getCityDetailList(conditions);
		int cityCount = this.adminSettingsService.getCityDetailCount(conditions);
		super.pageCount = (int) Math.ceil(cityCount / (double) super.dataListLimit);

		return SUCCESS;
	}

	public String getLocalCityName() {
		return localCityName;
	}

	public void setLocalCityName(String localCityName) {
		this.localCityName = localCityName;
	}

	public List<CityDetailBean> getCityDetailList() {
		return cityDetailList;
	}

	public void setCityDetailList(List<CityDetailBean> cityDetailList) {
		this.cityDetailList = cityDetailList;
	}

}
